package com.platform.service.impl;

import com.platform.cache.J2CacheUtils;
import com.platform.dao.LotteryConfigDao;
import com.platform.entity.LotteryConfigEntity;
import com.platform.service.LotteryConfigService;
import com.platform.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 抽奖配置Service实现类
 *
 * @author liweihai
 * @email liweihai12345@sina.com
 * @date 2019-04-16 19:25:00
 */
@Service("lotteryConfigService")
public class LotteryConfigServiceImpl implements LotteryConfigService {
    @Autowired
    private LotteryConfigDao lotteryConfigDao;

    @Override
    public LotteryConfigEntity queryObject(Integer id) {
        return lotteryConfigDao.queryObject(id);
    }

    @Override
    public List<LotteryConfigEntity> queryList(Map<String, Object> map) {
        return lotteryConfigDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return lotteryConfigDao.queryTotal(map);
    }

    @Override
    public int save(LotteryConfigEntity lotteryConfig) {
        //清理KEY="REDIS_LOTTERY_KEY"在Redis的缓存
        J2CacheUtils.clear(Constants.REDIS_LOTTERY_KEY);
        return lotteryConfigDao.save(lotteryConfig);
    }

    @Override
    public int update(LotteryConfigEntity lotteryConfig) {
        //清理KEY="REDIS_LOTTERY_KEY"在Redis的缓存
        J2CacheUtils.clear(Constants.REDIS_LOTTERY_KEY);
        return lotteryConfigDao.update(lotteryConfig);
    }

    @Override
    public int delete(Integer id) {
        //清理KEY="REDIS_LOTTERY_KEY"在Redis的缓存
        J2CacheUtils.clear(Constants.REDIS_LOTTERY_KEY);
        return lotteryConfigDao.delete(id);
    }

    @Override
    public int deleteBatch(Integer[] ids) {
        //清理KEY="REDIS_LOTTERY_KEY"在Redis的缓存
        J2CacheUtils.clear(Constants.REDIS_LOTTERY_KEY);
        return lotteryConfigDao.deleteBatch(ids);
    }

    @Override
    public List<LotteryConfigEntity> queryAllLottery() {
        return lotteryConfigDao.queryAllLottery();
    }
}
